package com.dkhseep.bigevent.service.impl;

import com.dkhseep.bigevent.service.FileUploadService;
import com.dkhseep.bigevent.util.AliOssUtil;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.UUID;

/**
 * 功能:
 * 作者:Dksheep
 * 日期:2024/10/1423:00
 */
@Service
public class FileUploadServiceImpl implements FileUploadService {
    @Override
    public String upload(MultipartFile file) throws IOException {
        String originalFilename = file.getOriginalFilename();
        String fileName= UUID.randomUUID()+originalFilename.substring(originalFilename.lastIndexOf("."));
        String url = AliOssUtil.uploadFile(fileName,file.getInputStream());
        return url;
    }
}
